function azimuth_intercepts = fix_targets_in_beam(azimuth_intercepts, centre_az_d, radar_bw, radar_dir, current_index)

[num_radars, num_targets] = size(azimuth_intercepts);

start_az_sorted_d = zeros(1, num_radars);
stop_az_sorted_d = zeros(1, num_radars);

for radar = 1:num_radars
  start_az_sorted_d(radar) = centre_az_d(radar) - radar_bw(radar)/2;
  stop_az_sorted_d(radar) = centre_az_d(radar) + radar_bw(radar)/2;
  
  for target = current_index+1:num_targets
    if start_az_sorted_d(radar) <= azimuth_intercepts(radar, target) ...
    && azimuth_intercepts(radar, target) <= stop_az_sorted_d(radar)
      if radar_dir(radar) >= 0
        if azimuth_intercepts(radar, target) < centre_az_d(radar)
          azimuth_intercepts(radar, target) = centre_az_d(radar);
        end
      elseif radar_dir(radar)
        if azimuth_intercepts(radar, target) > centre_az_d(radar)
          azimuth_intercepts(radar, target) = centre_az_d(radar);
        end
      end
    end
  end
end

end